package com.rgp.internalcommon.utils;

import java.math.BigDecimal;

/**
 * @author nhp
 * @version 1.0
 * @description TODO
 * @date 2024-04-15 15:44
 */
public class CalculatePriceUtils {
    public static String add(String origin,String extension){
        BigDecimal result = new BigDecimal(origin).add(new BigDecimal(extension));
        return result.toString();
    }

    public static String subtract(String first,String second){
        BigDecimal result = new BigDecimal(first).subtract(new BigDecimal(second));
        return result.toString();
    }

    public static String multiply(String first,String second,String origin){
        BigDecimal multiply = new BigDecimal(first).multiply(new BigDecimal(second));
        return add(origin,multiply.toString());
    }

    public static String divide(String first,String second){
        return new BigDecimal(first).divide(new BigDecimal(second),2,BigDecimal.ROUND_HALF_UP).toString();
    }
}